package com.fy.controll;

import com.fy.model.Shop;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * 商品控制层
 * djy
 * Created by Administrator on 2020/10/28 0028.
 */
@Controller
public class ShopController {
    public Logger logger = LoggerFactory.getLogger(ShopController.class);
    @RequestMapping("/shopList")
    public String shopList(Model model){
        logger.info("进入访问 /shopList ...");
        //System.out.println("进入shopList方法...");
        //去数据库查询所有的商品信息
        List<Shop> shops = new ArrayList<>();
        shops.add(new Shop(1,"笔记本",5000,"深圳"));
        shops.add(new Shop(2,"小米手机",3000,"北京"));
        model.addAttribute("shops",shops);
        logger.info("进入访问 /shopList 结束");
        return "shopList";
    }
}
